package cn.yoyo.tools;

import java.text.SimpleDateFormat;
import java.util.Date;

public class GetTime {
    public static String getDate(Date date) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(date);
    }

    public static Date getSqlDate(String date) {
        if (date == null || "".equals(date)) return null;
        SimpleDateFormat format = new SimpleDateFormat(date);
        java.util.Date d = null;
        try {
            d = format.parse(date);
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        return new java.sql.Date(d.getTime());
    }
}
